<template>
  <div>
    <div class="container">
      <div>
        <el-form :model="formInline" ref="formInline" class="select-submit-form">
          <el-row type="flex">
            <el-col :span="8">
              <el-form-item label="大病赔案号" prop="caseNo">
                <el-input v-model="formInline.caseNo" placeholder="请输入大病赔案号"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="被保险人" prop="insuredName">
                <el-input v-model="formInline.insuredName" placeholder="请输入被保险人"></el-input>
              </el-form-item>
            </el-col>
            <el-col :span="8">
              <el-form-item label="证件号" prop="documentNo">
                <el-input v-model="formInline.documentNo" placeholder="请输入证件号"></el-input>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row type="flex">
            <el-col :span="8">
              <el-form-item label="任务状态" prop="taskState">
                <el-select placeholder="请选择" v-model="formInline.taskState">
                  <el-option
                    v-for="item in MedType"
                    :key="item.codeCode"
                    :label="item.codeCName"
                    :value="item.codeCode">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="24">
              <div class="select-btn-group">
                <el-button type="primary" @click="onSubmitCaseReopenAudit">查询</el-button>
                <el-button type="primary" @click="resetForm('formInline')">重置</el-button>
              </div>
            </el-col>
          </el-row>
        </el-form>
      </div>
      <template>
        <div>
          <el-divider></el-divider>
        </div>
      </template>
      <el-table
        :data="tableData"
        class="table"
        ref="multipleTable"
        header-cell-class-name="table-header"
        style="margin: 30px 0;border: 1px solid #d6d9d8;"
        v-loading="loading"
        element-loading-text="Loading"
      >
        <el-table-column prop="caseNo" label="大病赔案号" align="center" width="170">
          <template  slot-scope="scope">
            <a href="#" style="color: #409EFF" @click="save(scope.$index, scope.row)">{{scope.row.caseNo}}</a>
          </template>
        </el-table-column>
        <el-table-column prop="policyNo" label="保单号"  align="center" width="170"></el-table-column>
        <el-table-column prop="insuredName" label="被保险人" align="center"></el-table-column>
        <el-table-column prop="documentNo" label="证件号"  align="center"></el-table-column>
        <el-table-column prop="handlerCode" label="处理人工号"  align="center"></el-table-column>
        <el-table-column prop="handlerName" label="处理人名称" ></el-table-column>
        <el-table-column prop="handleComrName" label="处理人机构" width="150" align="center"></el-table-column>
        <el-table-column prop="flowInTime" label="流入时间"  align="center"></el-table-column>
        <el-table-column prop="taskState" label="状态"  align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.taskState == '01'">待处理</span>
            <span v-if="scope.row.taskState == '03'">已处理</span>
            <span v-if="scope.row.taskState == '04'">已退回</span>
          </template>
        </el-table-column>
        <!-- <el-table-column label="操作" width="auto" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.taskState == '03'">
              <el-button
                type="text"
                @click="save(scope.$index, scope.row)">查看
            </el-button>
            </span>
            <span v-else="scope.row.taskState == '01'">
              <el-button
                type="text"
                @click="save(scope.$index, scope.row)">审核
            </el-button>
            </span>
          </template>
        </el-table-column> -->

      </el-table>
      <div class="pagination" v-show="this.tableData.length>0">
        <div class="index_page">
          <el-pagination :current-page="pagination.currentPage" :page-size="pagination.rowsNumber"
                         :page-sizes="[10, 20, 50, 100]"
                         :total="pagination.totalPage" background layout="prev, pager, next,sizes,total,jumper"
                         @size-change="handleSizeChange" @current-change="queryFun">
          </el-pagination>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
  import * as api from '@/api/baseDate'

  export default {
    name: 'rengonghepei',
    data() {
      return {
        loading: false,
        query: {
          address: '',
          name: '',
          pageIndex: 1,
          pageSize: 10
        },
        tableData: [],
        multipleSelection: [],
        delList: [],
        editVisible: false,
        pageTotal: 3,
        form: {},
        idx: -1,
        id: -1,
        formInline: {
          user: '',
          region: ''
        },
        caseReopenAuditDemo: {},
        MedType: [
          {
            codeCode: '01',
            codeCName: '待处理',
          },
          {
            codeCode: '03',
            codeCName: '已处理',
          }
        ],
        pagination: {
          currentPage: 1, // 当前页
          rowsNumber: 10, // 每页条数
          totalPage: 12 // 总条数
        },
      };
    },
    created() {
    },
    methods: {
      // 按条件查询
      onSubmitCaseReopenAudit() {
        this.loading = true;
        var data = {
          // "caseNo":"1633766385160",
          "pageIndex": this.pagination.currentPage,
          "rowsNumber": this.pagination.rowsNumber,
          "caseNo": this.formInline.caseNo,
          "insuredName": this.formInline.insuredName,
          "documentNo": this.formInline.documentNo,
          "taskState": this.formInline.taskState,
          "comCode":Cookies.get("makeCom")
        }
        api.getQueryRecase(data
        ).then(res => {
          this.loading = false,
          this.tableData = res.data.list
          if (res.data.resultCode) {
            if (res.data.resultCode !== '0000') {
              this.$message.error(res.data.resultMsg);
            } else {
              this.pagination.totalPage = res.data.total;
            }
          } else {
            this.list = res.data;
          }
        })
      },
      //重置
      resetForm(formName) {
        debugger
        this.$refs[formName].resetFields();
      },
      save(index, row) {
        if(row.taskState == '01'){
          debugger
          api.taskCheck({
            "processId": row.processId,
            "handleComrCode":Cookies.get("makeCom"),
            "handleComrName":Cookies.get("cMakeCom"),      
            "handlerCode":Cookies.get("userCode"),
            "handlerName":Cookies.get("userName"),
            "reqFlag": "check"
          }).then(res => {
            if(res.data.resultCode=="0000"){                 
             this.getDetail(row)
            }else{
              this.$alert(res.data.resultMsg,'提示', {
                  confirmButtonText: '确定'
                });
            }
          })          
        }else{
          this.getDetail(row)
        }      
      },
      getDetail(row){
        this.caseReopenAuditDemo = row,
          this.$router.push({
            name: 'caseReopenAuditDemo',
            query: {
              caseReopenAuditDemo: JSON.stringify(this.caseReopenAuditDemo),
              processId:row.processId
            }
          })
      },
      handleSizeChange(pageSize) { // 改变当前页条数事件
        this.pagination.currentPage = pageSize
        this.onSubmitCaseReopenAudit()
        /* let pageIndex = this.pagination.currentPage;
         this.querySettleAuditTaskList(pageIndex,pageSize);*/
      },
      queryFun(pageNum) { // 改变当前页事件
        this.pagination.rowsNumber = pageNum
        this.onSubmitCaseReopenAudit()
        /* let rowsNumber = this.pagination.rowsNumber;
         this.querySettleAuditTaskList(pageNum,rowsNumber);*/
      },


      // 分页导航
      handlePageChange(val) {
        this.$set(this.query, 'pageIndex', val);
      },
      onSubmit() {
        console.log('submit!');
      }
    }
  };
</script>
<style lang="scss" scoped></style>

